package com.hpeng.sys.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.hpeng.sys.dao.ProdStatusDao;
import com.hpeng.sys.model.ProdStatusMst;
import com.hpeng.util.GenericDaoImpl;

@Component("prodStatusDao")  
public class ProdStatusDaoImpl extends GenericDaoImpl<ProdStatusMst,String> implements ProdStatusDao{
	public String[] getByStatus(String Status){
		List<ProdStatusMst> proStatusMsts = null;
		if(Status.equals("JB")){
			proStatusMsts = getByHql("from ProdStatusMst prodStatusMst where prodStatusMst.subdesc like '%经办已录入%' or prodStatusMst.subdesc like '%经办已申请%'");
		}else if(Status.equals("BMLD")){
			proStatusMsts = getByHql("from ProdStatusMst prodStatusMst where prodStatusMst.subdesc like '%部门领导已录入%' or prodStatusMst.subdesc like '%经办已上报%'");
		}else if(Status.equals("JLD")){
			proStatusMsts = getByHql("from ProdStatusMst prodStatusMst where prodStatusMst.subdesc like '%部门领导已上报%'");
		}else if(Status.equals("ALL")){
			proStatusMsts = getAll();
		}
		String[] subcode = new String[proStatusMsts.size()];
		for(int i = 0;i < proStatusMsts.size();i++){
			subcode[i] = proStatusMsts.get(i).getSubcode();
		}
		return subcode;
	}
	public ProdStatusMst getStatus(String main,String over){
		List<ProdStatusMst> proStatusMsts = null;
		proStatusMsts = getByHql("from ProdStatusMst prodStatusMst where prodStatusMst.statuscode='"+main+"' and prodStatusMst.subcode='"+over+"'");
		String newProStatusMst = Integer.parseInt(proStatusMsts.get(0).getCreateby()) + 1 + "";
		proStatusMsts = getByHql("from ProdStatusMst prodStatusMst where prodStatusMst.statuscode='"+main+"' and prodStatusMst.createby='"+newProStatusMst+"'");
		return proStatusMsts.get(0);
	}
}
